﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once
#include "GnufBase.h"
#include "GnufImpl.h"
#include "GnufInfo.h"

namespace gnuf {

    class ButtonControl;

    namespace impl { class GNUF_IMPL_CLASS(Usurper);  }
    class GNUF_BASE_EXPORT Usurper final : public gcmp::WeakReferenceable
    {
        GNUF_IMPL_USE(Usurper);
        
    public:
        explicit Usurper();
        ~Usurper();

        static Usurper * get();

        ///\return Return true if enabled.
        bool isEnabled() const;
    };
    
}

namespace gnuf { namespace impl {

    class GNUF_IMPL_CLASS(Usurper)
    {
        GNUF_IMPL_USED_BY(Usurper);

    public:
        explicit GNUF_IMPL_CLASS(Usurper)(Usurper * pUsurper);
        ~GNUF_IMPL_CLASS(Usurper)();

        void setEnabled(bool val) { m_enabled = val; }
        bool isEnabled() const { return m_enabled; }

        void setLicence(const std::wstring & val) { m_licence = val; }
        const std::wstring & licence() const { return m_licence; }

        void setSplashScreen(const std::wstring & val) { m_splashScreen = val; }
        const std::wstring splashScreen() const { return m_splashScreen; }

        void setAppIcon(const std::wstring & val);
        const std::wstring appIcon() const { return m_appIcon; }

        void setModuleBehavior(const std::wstring& val);
        const std::wstring moduleBehavior() const { return m_moduleBehavior; }
        
        void refresh(const std::wstring & id, const Info &);
        void refresh(const std::wstring & id, ButtonControl *);

    private:
        void refresh(ButtonControl *, const Info &) const;
    
        bool m_enabled = false;     // disabled, by default
        std::wstring m_licence;     // empty, by default
        std::wstring m_splashScreen;// empty, by default
        std::wstring m_appIcon;     // empty, by default
        std::wstring m_moduleBehavior; // empty, by default
        std::unordered_map< std::wstring, Info > m_waitingToRefresh;
    };

} }
